/*
* Conditions Of Use
*
* This software was developed by employees of the Sigmatrix(Beijing) Corporation.
* This software is provided by sigmatrix as a service and is expressly
* provided "AS IS."  Sigmatrix MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
* OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
* AND DATA ACCURACY.  Sigmatrix does not warrant or make any representations
* regarding the use of the software or the results thereof, including but
* not limited to the correctness, accuracy, reliability or usefulness of
* the software.
*
* Permission to use this software is contingent upon your acceptance
* of the terms of this agreement.
*
*/
package com.sigmatrix.h5.web.controller.common;

import org.apache.commons.lang3.StringUtils;

import com.sigmatrix.h5.enums.ResponseEnum;
import com.sigmatrix.h5.request.Request;
import com.sigmatrix.h5.response.Response;
import com.sigmatrix.h5.utils.Cons;

/**
 *@ClassName: BaseController
 *@Description: 控制器基类
 *@author youjun
 *@date 2017年6月22日 上午11:37:28
 */
public class BaseController {

	/**
	 *@Title: validateBasicParams
	 *@Description: 验证公共参数
	 *@return Response
	 *@author youjun
	 *@date 2017年7月8日 下午2:54:14
	 *@param request
	 *@param isValidTerminalId 是否验证终端ID
	 */
	protected Response validateBasicParams(final Request request, final boolean isValidTerminalId) {
		if(request==null) {
			return new Response(ResponseEnum.PARAM_NULL);
		}
		if(StringUtils.isBlank(request.getEnterpriseCode())) {
			return new Response(Cons.RESPONSE_CODE_PARAM_INVALID, "企业code不能为空");
		}
		if(request.getUserId()==null) {
			return new Response(Cons.RESPONSE_CODE_PARAM_INVALID, "用户ID不能为空");
		}
		return new Response(ResponseEnum.SUCCESS);
	}
}
